/**
 * @author : cyb1010
 * @date   : 2024-06-04 11:33:41
 * @file   : build.cpp
 */
#include <bits/stdc++.h>
using namespace std;
#define fo(s) freopen(s ".in", "r", stdin), freopen(s ".out", "w", stdout)
#define fi first
#define se second
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
void ckmx(int &x, int y) { x < y && (x = y); }
int __, n, a[8010], f[310][310][310], ans;
int main() {
    fo("build");
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 0; i <= n; i++)
        for (int j = 0, _j = n + 1; i + j <= n; j++, _j--) {
            for (int k = 0, u = i + j, _u = n - u + 1; ~u; k++, _u++, u--) {
                if (i && k) ckmx(f[i][j][k], f[i - 1][j][k - 1] + (a[i] == k));
                if (i && u) ckmx(f[i][j][k], f[i - 1][j][k] + (a[i] == _u));
                if (j && k) ckmx(f[i][j][k], f[i][j - 1][k - 1] + (a[_j] == k));
                if (j && u) ckmx(f[i][j][k], f[i][j - 1][k] + (a[_j] == _u));
            }
        }
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= n; j++) ckmx(ans, f[i][n - i][j]);
    cout << n - ans << '\n';
    return 0 ^ __ ^ 0;
}